package com.zc.operator.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import com.zc.operator.domain.ChargeOperatorUser;
import com.zc.operator.mapper.ChargeOperatorUserMapper;
import com.zc.operator.service.IChargeOperatorUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import static com.ruoyi.common.utils.SecurityUtils.getDeptId;
import static com.ruoyi.common.utils.SecurityUtils.getUsername;


/**
 * 运营商用户Service业务层处理
 *
 * @author glb
 * @date 2023-05-16
 */
@Service
public class ChargeOperatorUserServiceImpl implements IChargeOperatorUserService
{
    @Autowired
    private ChargeOperatorUserMapper chargeOperatorUserMapper;

    /**
     * 查询运营商用户
     *
     * @param operatorId 运营商用户主键
     * @return 运营商用户
     */
    @Override
    @DataScope(deptAlias = "d")
    public ChargeOperatorUser selectChargeOperatorUserByOperatorId(Long operatorId)
    {
        return chargeOperatorUserMapper.selectChargeOperatorUserByOperatorId(operatorId);
    }

    /**
     * 查询运营商用户列表
     *
     * @param chargeOperatorUser 运营商用户
     * @return 运营商用户
     */
    @Override
    @DataScope(deptAlias = "d")
    public List<ChargeOperatorUser> selectChargeOperatorUserList(ChargeOperatorUser chargeOperatorUser)
    {
        return chargeOperatorUserMapper.selectChargeOperatorUserList(chargeOperatorUser);
    }

    /**
     * 新增运营商用户
     *
     * @param chargeOperatorUser 运营商用户
     * @return 结果
     */
    @Override
    public int insertChargeOperatorUser(ChargeOperatorUser chargeOperatorUser)
    {
        chargeOperatorUser.setDeptId(getDeptId());
        chargeOperatorUser.setCreateBy(getUsername());
        chargeOperatorUser.setCreateTime(DateUtils.getNowDate());
        return chargeOperatorUserMapper.insertChargeOperatorUser(chargeOperatorUser);
    }

    /**
     * 修改运营商用户
     *
     * @param chargeOperatorUser 运营商用户
     * @return 结果
     */
    @Override
    public int updateChargeOperatorUser(ChargeOperatorUser chargeOperatorUser)
    {
        chargeOperatorUser.setUpdateBy(getUsername());
        chargeOperatorUser.setUpdateTime(DateUtils.getNowDate());
        return chargeOperatorUserMapper.updateChargeOperatorUser(chargeOperatorUser);
    }

    /**
     * 批量删除运营商用户
     *
     * @param operatorIds 需要删除的运营商用户主键
     * @return 结果
     */
    @Override
    public int deleteChargeOperatorUserByOperatorIds(Long[] operatorIds)
    {
        return chargeOperatorUserMapper.deleteChargeOperatorUserByOperatorIds(operatorIds);
    }

    /**
     * 删除运营商用户信息
     *
     * @param operatorId 运营商用户主键
     * @return 结果
     */
    @Override
    public int deleteChargeOperatorUserByOperatorId(Long operatorId)
    {
        return chargeOperatorUserMapper.deleteChargeOperatorUserByOperatorId(operatorId);
    }
}
